import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';

import { HttpServer } from '@core/net/http-server';
import {AutoPaperQuestionNum, Paper, QuestionNumData} from '../model/paper';
import {UrlManager} from "@shared/url/url.manager";
import {PageInfo} from "@core/model/pageInfo";
import {Question} from "../../question/model/question";


@Injectable()
export class PaperService {
  constructor(
    private httpServer: HttpServer
  ) { }

  private _paper: Paper = new Paper();

  get paper(): Paper {
    return this._paper;
  }
  getAutoPaperQuestionNumByDifficulty(difficulty:string,knowledgeName:string):Observable<AutoPaperQuestionNum>{
    return this.httpServer.get(UrlManager.api.paper.getAutoPaperQuestionNumByDifficulty,{difficulty:difficulty,knowledgeName:knowledgeName});
  }
  getQuestionByKnowledge(knowledgeListValue:string):Observable<any[]>{
    return this.httpServer.get(UrlManager.api.paper.getQuestionByKnowledge,{knowledgeListValue:knowledgeListValue});
  }
  getKnowledgeList():Observable<any[]>{
    return this.httpServer.get(UrlManager.api.paper.getKnowledgeList,{});
  }
  getAllPaperByPage(pageNo: number, pageSize: number): Observable<PageInfo<Paper>> {
    return this.httpServer.get(UrlManager.api.paper.getAllPaperByPage, {
      pageNo: pageNo,
      pageSize: pageSize
    });
  }
  getQuestionNumber(): Observable<QuestionNumData> {
      return this.httpServer.get(UrlManager.api.paper.getQuestionNumber, {  });
    }

  exportPaper(paper:Paper):Observable<boolean> {
    return this.httpServer.post(UrlManager.api.paper.exportPaper, paper);
  }

  // getUserByName(userName: string): Observable<Question> {
  //   return this.httpServer.get(UrlManager.user.getUserByNameUrl, { account: userName });
  // }
  //
  // exportQuestionByIds(idsArr:string):Observable<boolean> {
  //   return this.httpServer.get(UrlManager.api.question.exportQuestionByIds, { idsArr: idsArr });
  // }
  //
  // getAllQuestionByPage(pageNo: number, pageSize: number): Observable<PageInfo<Question>> {
  //   return this.httpServer.get(UrlManager.api.question.getAllQuestionByPage, {
  //     pageNo: pageNo,
  //     pageSize: pageSize
  //   });
  // }
  //
  // getQuestionById(id: number): Observable<Question> {
  //   return this.httpServer.get(UrlManager.api.question.getQuestionById, { id: id });
  // }
  //
  // addQuestion(question:Question): Observable<boolean> {
  //   return this.httpServer.post(UrlManager.api.question.addQuestion, question);
  // }
  //
  // encriptPwd(user: Question): Observable<string> {
  //   return this.httpServer.post(UrlManager.user.encryptPwdPUrl, user);
  // }
  //
  // updateQuestion(question: Question): Observable<boolean> {
  //   return this.httpServer.post(UrlManager.api.question.updateQuestion, question);
  // }
  //
  // deltetQuestion(id: number): Observable<boolean> {
  //   return this.httpServer.get(UrlManager.api.question.deltetQuestion, {
  //     id: id
  //   });
  // }
  //
  // getUserNameCount(accout: string): Observable<Question> {
  //   return this.httpServer.get(UrlManager.user.getUserNameCount, {
  //     account: accout
  //   });
  // }
}
